#ifndef __OTHELLO_H__
#define __OTHELLO_H__

// 1. Othello piece
// 2. Player
// 3. Board for players to paly the game
// 4. Game

// Scenarios
// 1. Game initialized
// 2. User input a piece to a specific location on the board
// 3. Game needs to check whether the input is valid
// 4. Find the opponent's pieced to be flipped.
// 5. Reconfigure the piece board
// 5. Whether there is a winner in the game
// 6. The other user input the piece
// 7. repeat the above procedure

enum COLOR {
    WHITE = 0,
    BLACK = 1
};

class Timer {
public:
    Timer(unsigned int num_secs);
    ~Timer();

    void Reset();

    unsigned int getRemainingTime();
    bool Eclipse();

private:
    unsigned int total_secs_;
    unsigned int eclipsed_secs_;
};

class Piece {
public:
    Piece(COLOR color);
    ~Piece();

    COLOR getColor();

private
    COLOR color_;
};


class Player {
public:
    Player(char *name);
    ~Player();

    void setID(unsigned int id);
    unsigned int getID();

    void setPlayColor(COLOR color);
    COLOR getPlayColor();

    bool playPiece(int &x, int &y);

    void win(bool is_win);

    unsigned int getNumOfWinGames();
    unsigned int getNumOfLostGames();

private:
    char name_[256];
    unsigned int id_;

    unsigned int win_num_;
    unsigned int lose_num_;
};

class Board {
public:
    Board(int width, int height);
    ~Board();

    void display();
    // Put a piece in the location
    bool playPiece(COLOR color, int x, int y);

    // Each color replace one player
    bool calcCapturedPiece(COLOR color, int &x, int &y);

    bool reconfigure(COLOR color, int x, int y);

private:
    Piece *board_;
    int width_;
    int height_;
};

class Game {
public:
    Game();
    ~Game();

    bool init();

    Player *getNextPlayer();

    Player *win();

private:
    Board *board;
    Player player1_;
    Player player2_;

    Timer *timer1_;
    Timer *timer2_;
};

#endif
